<?php

/**
 * Created by PhpStorm.
 * User: zhanghua
 * Date: 18-9-23
 * Time: 下午6:20
 */

namespace app\http\middleware;

use app\sun\service\AdminService;

class SunAuth
{
    public function handle($request, \Closure $next)
    {

        if(!AdminService::checkLogin()){ //Not login
            if($request->path() !== 'sun/public/login'){
                return redirect('/sun/public/login');
            }

        }else{

            if($request->path() === 'sun/public/login')
            {
                return redirect('/sun/index/index');
            }

        }

        return $next($request);
    }
}